package com.victor.controller.app;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.victor.entity.CollectionLabel;
import com.victor.service.CollectionService;
import com.victor.utils.Msg;

@RestController
@RequestMapping("/collection")
public class CollectionController {
	@Autowired
	private CollectionService collectionService;
	
	/**
	 * 添加收藏标签
	 * @param myCollection
	 * @return
	 */
	@RequestMapping("/addlabel")
	public Msg add(CollectionLabel myCollection) {
		if (myCollection == null || myCollection.getUid() == null || myCollection.getUid().isEmpty()) {
			return Msg.fail("入参错误");
		}
		boolean b = collectionService.add(myCollection);
		if (!b) {
			return Msg.fail("添加标签失败");
		}
		return Msg.success();
	}
	/**
	 * 查询全部标签
	 * @param page
	 * @param row
	 * @param uid
	 * @return
	 */
	public Msg findAllLabel(int page,int row,String uid) {
		if (uid == null || uid.isEmpty()) {
			return Msg.fail("入参错误");
		}
		PageInfo< CollectionLabel> pageInfo = collectionService.selAllLabel(page,row,uid);
		return Msg.success().add("info", pageInfo);
	}

}
